home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-13
/
me_cd22.zip
/
MUTT2.ZIP
/
INDENT.MUT
< prev
next >
Wrap
Text File
|
1992-04-27
|
2KB
|
53 lines
;; indent.mut : Shift a block left or right
;; A block is all the lines of text between the dot and mark inclusive.
;; With no arg: asks for the amount to shift the region. Positive
;; for right shift, negative for left shift.
;; With arg (ie ^U): shifts the region by the difference between the dot
;; and the first nonblank character on that line.
;; eg use this to shift the top line of the region over to the cursor.
;; Removes white space from blank lines.
;; When doing a negative shift, text won't be shifted left of the left
;; margin.
;; C Durland Public Domain
(include wspace.mut)
(include runblock.mut)
(defun
MAIN
{
(bind-to-key "indent-rigidly" "C-xC-i")
}
indent-line (int shift-count) HIDDEN
{
(int col)
(skip-whitespace)(col (current-column)) ; count blanks
(arg-prefix 0)(cut-line) ; move text to left margin
(end-of-line)
(if (!= 1 (current-column)) ; indent if line not blank
{
(beginning-of-line)
(to-col (+ col shift-count)) ; indent text n more columns
})
}
indent-rigidly
{
(int col shift-count)
(if (== 0 ;; if no shifting the don't do anything
(shift-count ;; calculate the amount to shift
(if (arg-flag) ;; by looking at the point
{
(col (current-column))
(beginning-of-line)(skip-whitespace)
(- col (current-column))
}
;; by asking
(convert-to NUMBER (ask "indent region by n spaces. n = "))
)))
(done))
(run-pgm-on-block (floc indent-line) shift-count)
}
)